package com.pg_chat.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.HashMap;

@Data
@Component
@Configuration
@PropertySource(value = {"classpath:config.yaml"}, factory = YamlSourceFactory.class)
@ConfigurationProperties(prefix = "config.yaml")
@Service("ymlProperties")
public class YmlProperties implements Serializable {
    private String adminName;
    private Integer level;
    private HashMap<String,String> messages;
    private HashMap<String,String> emailConfig;
    private HashMap<String,String> smsConfig;
    private boolean md5verify;

    private HashMap<String,String> valueRegex;



    public YmlProperties() {
    }

    public String getAdminName() {
        return adminName;
    }

    public void setAdminName(String adminName) {
        this.adminName = adminName;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    public HashMap<String, String> getMessages() {
        return messages;
    }

    public void setMessages(HashMap<String, String> messages) {
        this.messages = messages;
    }

    public boolean isMd5verify() { return md5verify; }

    public void setMd5verify(String md5verify) { this.md5verify = "true".equals(md5verify); }

    public HashMap<String, String> getValueRegex() {
        return valueRegex;
    }

    public void setValueRegex(HashMap<String, String> valueRegex) {
        this.valueRegex = valueRegex;
    }

    public HashMap<String, String> getEmailConfig() {
        return emailConfig;
    }

    public void setEmailConfig(HashMap<String, String> emailConfig) {
        this.emailConfig = emailConfig;
    }

    public HashMap<String, String> getSmsConfig() {
        return smsConfig;
    }

    public void setSmsConfig(HashMap<String, String> smsConfig) {
        this.smsConfig = smsConfig;
    }

    @Override
    public String toString() {
        return "YmlProperties{" +
                "adminName='" + adminName + '\'' +
                ", level=" + level +
                ", messages=" + messages +
                '}';
    }
}
